{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "40ac81a7-b717-4b50-b1db-aa7707a0bcf6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入字符串： dp jpojo; jdq;j ojjl;j j;ouopqjl; hilb \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "所有字母的总数为：   39\n",
      "英文字母出现的次数： 28\n",
      "数字出现的次数：     0\n",
      "空格出现的次数：     6\n",
      "其他字符出现的次数： 5\n"
     ]
    }
   ],
   "source": [
    "countLetter = 0; countNumber = 0; countSpace = 0; countOther = 0;countAll = 0\n",
    "strs=input(\"请输入字符串：\")\n",
    "for i in range(len(strs)):\n",
    "    ch=strs[i]\n",
    "    countAll+=1\n",
    "    if (str.isalpha(ch)): countLetter+=1\n",
    "    elif(str.isdigit(ch)):countNumber+=1\n",
    "    elif(str.isspace(ch)):countSpace+=1\n",
    "    else:countOther+=1\n",
    "print(\"所有字母的总数为：  \", countAll)\n",
    "print(\"英文字母出现的次数：\", countLetter)\n",
    "print(\"数字出现的次数：    \", countNumber)\n",
    "print(\"空格出现的次数：    \", countSpace)\n",
    "print(\"其他字符出现的次数：\", countOther)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b9f02b9-4c4d-4e64-9058-66885dd29a73",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
